﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExpertMIS.Brokers;

namespace ExpertMIS.Service
{
    /// <summary>
    /// 检查帐号是否有效（未重名，则有效）
    /// </summary>
    public partial class CheckDupAccount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["account"]))
            {
                Response.Write("'参数无效！'");
            }
            else
            {
                Response.Write(CheckAccountIsValid(Request["account"]) ? "true" : "false");
            }
        }


        /// <summary>
        /// 检查当前帐号是否已存在
        /// </summary>
        /// <returns></returns>
        private bool CheckAccountIsValid(string account)
        {
            try
            {
                ADMUserBroker broker = new ADMUserBroker();
                if (broker.GetUserByAccount(account) == null)
                {
                    return true;
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
    }
}
